package demo.ybt;

import java.util.Scanner;

public class P1320 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] t=new int[n];

        for(int j=0;j<n;j++){
            t[j]=sc.nextInt();
        }

        int avg = 0;
        for (int i = 0; i < t.length; i++) {
            avg += t[i];
        }

        if (avg % t.length != 0) {
            //不能均分直接返回-1
           // System.out.print(-1);
        }

        //求得均值
        avg /= t.length;

        int count = 0;
        for (int i = 0; i < t.length; i++) {
            if (avg != t[i] && i + 1 < t.length) {
                t[i + 1] += t[i] - avg;
                t[i] = avg;
                count++;
            }
        }
        System.out.print(count);

    }

}
